
<?php include_once(dirname(__FILE__) . '/../general/head.php'); ?>

<?php include_once(dirname(__FILE__) . '/../general/header.php'); ?>

<?php include_once('left.php'); ?>
<div id="page-wrapper">


    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">Đánh giá thái độ</h1>
        </div>
        <!-- /.col-lg-12 -->
    </div>
    <!-- /.row -->
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    Danh sách
                </div>
                <!-- /.panel-heading -->
                <div class="panel-body">
                    <div class="form-group">
                        <label>Đợt đánh giá</label>
                        <input type="text" name="name" class="form-control" style="width: 50%;" readonly="readonly" value="<?php echo $evaluationInfo['name']; ?>" />
                    </div>
                    

                    <?php
                    if ($rows == false) {
                        ?>
                        Hiện tại không có kết quả nào!
                        <br>
                    <?php } else { ?>

                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover" id="att-detail-results">
                                <thead>
                                    <tr>
                                        <th>TL code</th>
                                        <th>SS code</th>
                                        <th>RSM code</th>
                                        <!--<th width="40px">No</th>-->

                                        <th width="90px">Area</th>
                                        <th width="110px">Location</th>
                                        <th width="70px">Mã NV</th>
                                        <th width="50px">Title</th>
                                        <th>Họ và tên</th>

                                        <!--<th>Tên đợt</th>-->
                                        <th>&nbsp;</th>
                                        <th>Số điểm</th>
                                        <th>Xếp loại</th>
                                        <th>Ngày đánh giá</th>
                                        
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $i = 1;
                                    foreach ($rows as $row) {
                                        ?>
                                        <tr>
                                            <td><?php echo $row['teamleader_code']; ?></td>
                                            <td><?php echo $row['supervisor_code']; ?></td>
                                            <td><?php echo $row['rsm_code']; ?></td>
                                            <!--<td><?php echo $i; ?></td>-->

                                            <td><?php echo $regionDic[$row['rsm_code']]; ?></td>
                                            <td><?php echo $row['location']; ?></td>
                                            <td><?php echo $row['code']; ?></td>
                                            <td><?php echo $row['title']; ?></td>
                                            <td><?php echo $row['name']; ?></td>

                                            <!--<td><?php echo $evaluationInfo['name']; ?></td>-->
                                            <td>
                                                <?php
                                                if (strtotime($row['starting_day']) < strtotime(date('Y-5-1'))) { // làm việc trước ngày 1/5 mới xét
                                                    if ($row['attResult']['status'] == 'confirmed') {
                                                        echo ucfirst($row['attResult']['status']);
                                                    } else {
                                                        if (!$row['attResult']['rated_day']) {
                                                            ?>
                                                            <a href="<?php echo site_url(get_folder($loggedUser['title']) . '/attitude_user_details/add/' . $row['id']); ?>">Đánh giá</a>
                                                        <?php } else { ?>
                                                            <?php if ($row['attResult']['status'] == 'rejected') { ?>
                                                                Rejected<br/>
                                                            <?php } else if ($row['attResult']['status'] == 'review') { ?>
                                                                Waiting review<br/>
                                                            <?php } ?>
                                                            <a href="<?php echo site_url(get_folder($loggedUser['title']) . '/attitude_user_details/edit/' . $row['id']); ?>">Đánh giá lại</a>

                                                            <?php
                                                        }
                                                    }
                                                }
                                                ?>
                                            </td>
                                            <td><?php echo $row['attResult']['score']; ?></td>
                                            <td><?php echo color_attitude($row['attResult']['score'], $settings['att_high_score'], $settings['att_medium_score'], $row['attResult']['rating']); ?></td>
                                            <td><?php echo $row['attResult']['rated_day']; ?></td>
                                            
                                        </tr>
                                        <?php
                                        $i++;
                                    }
                                    ?>
                                </tbody>
                            </table>

                        </div>
                    <?php } ?>
                    <br>
                </div>
                <!-- /.panel-body -->
            </div>
        </div>
    </div>


</div>
<script>
    $(document).ready(function() {
        $('#att-detail-results').dataTable({
            "iDisplayLength": 50,
            "scrollX": true,
            "sScrollX": "120%",
            "order": [[11, "desc"]],
            "columnDefs": [
                {
                    "targets": [0],
                    "visible": false,
                    "searchable": false,
                    "orderData": [0, 1]
                },
                {
                    "targets": [1],
                    "visible": false,
                    "searchable": false,
                    "orderData": [0, 1]
                },
                {
                    "targets": [2],
                    "visible": false,
                    "searchable": false,
                    "orderData": [0, 1]
                },
            ]
        });
    });
</script>

<?php include_once(dirname(__FILE__) . '/../general/footer.php'); ?>
